package com.actimize.dao.hibernate;


import com.actimize.dao.PayeeDao;
import com.actimize.model.Payee;

import org.springframework.stereotype.Repository;
import java.util.List;
import org.hibernate.Query;

	@Repository("payeeDao")
	public class PayeeDaoHibernate extends GenericDaoHibernate<Payee, Long> implements PayeeDao {

	    public PayeeDaoHibernate() {
	        super(Payee.class);
	    }

	    public Payee savePayee(Payee payee) {
	        if (log.isDebugEnabled()) {
	            log.debug("payee's id: " + payee.getPayeeId());
	        }
	        getSession().save(payee);
	        // necessary to throw a DataIntegrityViolation and catch it in UserManager
	        getSession().flush();
	        return payee;
	    }

		@Override
		@SuppressWarnings("unchecked")
	    public List<Payee> getPayees() {
			Query qry = getSession().createQuery("from Payee u order by upper(u.payeeName)");
			System.out.println("Query is ="+qry.getQueryString());
	        return qry.list();
		}
	}
